import request from '@/utils/request'

// 查询产品类型列表
export function listProduct(query) {
  return request({
    url: '/product/list',
    method: 'get',
    params: query
  })
}

// 查询产品类型详细
export function getProduct(id) {
  return request({
    url: '/product/' + id,
    method: 'get'
  })
}

// 新增产品类型
export function addProduct(data) {
  return request({
    url: '/product/',
    method: 'post',
    data: data
  })
}

// 修改产品
export function updateProduct(data) {
  return request({
    url: '/product/',
    method: 'put',
    data: data
  })
}

// 删除产品类型
export function deleteProduct(id) {
  return request({
    url: '/product/' + id,
    method: 'delete'
  })
}

export function batchUpdateProductStatus(data) {
  return request({
    url: '/product/batchUpdateStatus',
    method: 'post',
    data: data
  })
}

export function updateProductStatus(data) {
  return request({
    url: '/product/updateStatus',
    method: 'post',
    data: data
  })
}

export function changeProductIfIndex(id, ifIndex) {
  const data = {
    id,
    ifIndex
  }
  return request({
    url: '/product/changeIfIndex',
    method: 'post',
    data: data
  })
}

export function uploadMainImg(data) {
  return request({
    url: '/product/uploadMainImg',
    method: 'post',
    data: data
  })
}
